<template>
	<view class="head">
		<uni-search-bar  placeholder="请输入搜索内容" @confirm="confirm" v-model="searchKey"></uni-search-bar>
	</view>
</template>
<script>
	export default {
		name:"search-head",
		data() {
			return {
				searchKey:""
			};
		},
		props:['historyItem'],
		methods:{
			confirm(){
				this.getSearch()
			},
			// 
			getSearch(){
				uni.navigateTo({
					url:`../../pages/move_list/move_list?search=${this.searchKey}`
				})
				let historyList=uni.getStorageSync("history")
				if(historyList){
					let index=historyList.indexOf(this.searchKey)
					if(index>-1){
						historyList.splice(index,1)
					}
					historyList.unshift(this.searchKey)
					uni.setStorageSync("history",historyList)
				}else{
					uni.setStorageSync("history",[this.searchKey])
				}
				this.searchKey=""
			}
			
		},
		watch:{
			historyItem(value){
				this.searchKey=value
				this.getSearch()
			}
		}
	}
</script>

<style scoped>
	.head{
		position: relative;
		background-color:#98c8e6;
		padding-top: 180rpx;
		padding-bottom: 30rpx;
	}

</style>